package com.acwing.partition12;

import java.io.*;
import java.util.LinkedList;
import java.util.Queue;

/**
 * @author `RKC`
 * @date 2022/1/20 22:13
 */
public class AC1165单词环 {

    private static final int N = 700, M = (int) (1e5 + 10);
    private static int[] head = new int[N], element = new int[M], next = new int[M], weight = new int[M];
    private static int[] cnt = new int[N];
    private static double[] dist = new double[N];
    private static boolean[] inQueue = new boolean[N];

    private static int n = 0, idx = 0;

    private static final BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
    private static final BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(System.out));

    public static void main(String[] args) throws IOException {
        while (true) {
            n = Integer.parseInt(reader.readLine());
            if (n == 0) break;
            for (int i = 0; i < N; i++) head[i] = -1;
            idx = 0;
            for (int i = 0; i < n; i++) {
                String str = reader.readLine();
                if (str.length() < 2) continue;
                int u = (str.charAt(0) - 'a') * 26 + str.charAt(1) - 'a';
                int v = (str.charAt(str.length() - 2) - 'a') * 26 + str.charAt(str.length() - 1) - 'a';
                createEdge(u, v, str.length());
            }
            if (!spfa(0)) writer.write("No solution\n");
            else writer.write(binarySearch() + "\n");
        }
        writer.flush();
    }

    private static double binarySearch() {
        double left = 0, right = 1000;
        while (right - left > 1e-4) {
            double mid = (left + right) / 2;
            if (spfa(mid)) left = mid;
            else right = mid;
        }
        return left;
    }

    private static boolean spfa(double mid) {
        for (int i = 0; i < N; i++) {
            inQueue[i] = false;
            cnt[i] = 0;
        }
        Queue<Integer> queue = new LinkedList<>();
        for (int i = 0; i < 676; i++) {
            queue.add(i);
            inQueue[i] = true;
        }
        int sum = 0;
        while (!queue.isEmpty()) {
            int u = queue.poll();
            inQueue[u] = false;
            for (int i = head[u]; i != -1; i = next[i]) {
                int v = element[i];
                if (dist[v] < dist[u] + weight[i] - mid) {
                    dist[v] = dist[u] + weight[i] - mid;
                    cnt[v] = cnt[u] + 1;
                    if (++sum > 2 * n) return true;
                    if (cnt[v] >= N) return true;
                    if (inQueue[v]) continue;
                    inQueue[v] = true;
                    queue.add(v);
                }
            }
        }
        return false;
    }

    private static void createEdge(int u, int v, int w) {
        element[idx] = v;
        next[idx] = head[u];
        head[u] = idx;
        weight[idx++] = w;
    }
}
